<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>审核页面</title>
</head>
<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
<script src="../../layui/layui.js" charset="utf-8"></script>
<script  type ="text/javascript" src="../../res/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src ="../../res/js/Tools.js"></script>
<style>
    #fwb{
        margin-left:-5px;
        margin-right: 85px;

    }

    #butDiv{
        margin-left: 180px;
    }
    .layui-form-item{
        margin-top: 20px;
    }
    #selectDiv{
        width: 74%;
    }
</style>
<script>
    //全局同步
    $.ajaxSetup({

        async: false
    });
    // $(function () {
    //
    // })



</script>
<body>
<form class="layui-form" action=""  id="newForm"  method="post">
    <input type="hidden" name="attachId" id="attachId" >
    <input type="hidden" name="attachType" id="attachType" >

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">标题：</label>
            <div class="layui-input-block">
                <input type="text" name="attachName" id="attachName"  autocomplete="off" class="layui-input" disabled="disabled">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">发布人：</label>
            <div class="layui-input-block">
                <input type="text" name="attachPublisher" id="attachPublisher"   autocomplete="off" class="layui-input" disabled="disabled">
            </div>
        </div>
    </div>
<div class="layui-form-item">
    <label class="layui-form-label">审核：</label>
    <div class="layui-input-block"id="selectDiv">
        <select name="auditState" lay-verify="" id="auditState">
            <option value="30">通过</option>
            <option value="25">未通过</option>
        </select>
    </div>
    <div class="layui-form-item layui-form-text" id="fwb">
        <label class="layui-form-label">审核意见：</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容"  class="layui-textarea" name="auExp" lay-verify="attachContent" id="auExp"></textarea>
        </div>
    </div>
</div>
    <div class="layui-form-item" id="butDiv">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" id="submitBut">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <script>
        findId();
        var form=null;//用来监听提交按钮的
        layui.use('form', function(){
            form  = layui.form;
            layer = layui.layer;
            //监听提交
            form.on('submit(formDemo)', function(data){
                $("#submitBut").attr("disabled" , "true");
                var formDate = new FormData(document.getElementById("newForm"));
                var url="../../../atsAttachmentController/UpdateAuditState";
                $.ajax({
                    url:url,
                    type:"post",
                    data:formDate,
                    processData:false,
                    contentType:false,
                    dataType:"json",
                    success:function(obj){
                        if(obj==1){
                            layer.msg('操作成功',{
                                icon:1,
                                time:1000//1秒关闭，如果不配置，默认是3秒
                            },function(){
                                //关闭当前层
                                //当你在iframe页面关闭自身时
                                $("#submitBut").removeAttr("disabled");
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                parent.tableIndex.reload();
                            });
                        }else{
                            $("#submitBut").removeAttr("disabled");
                            layer.msg(obj.msg);
                        }
                    },
                    error:function(e){
                        $("#submitBut").removeAttr("disabled");
                        layer.msg("操作错误");
                    }
                });
                return false;
            });

        });

        function findId() {
            //修改页面赋值
            var attachId=getQueryString("attachId");
            url="../../../atsAttachmentController/findById";
            data={attachId:attachId};
            $.post(url,data,function(obj){
                $("#attachId").val(obj.attachId);
                $("#attachName").val(obj.attachName);
                $("#attachPublisher").val(obj.attachPublisher);
                $("#attachType").val(obj.attachType);
            },"json");
        }

    </script>
</form>
</body>
</html>